﻿#ifndef SERIALPORTMANAGER_H
#define SERIALPORTMANAGER_H

#include "qserialport.h"
#include "qserialportinfo.h"
#include "qthread.h"

class LogSaver;

class SerialPortManager :public QSerialPort
{
  Q_OBJECT

  //状态位
private:
  bool serialPortListenerState;

  LogSaver* logSaver= Q_NULLPTR;
public:
  SerialPortManager(QObject* parent = Q_NULLPTR);
  ~SerialPortManager();

  //信号和槽
signals:
  void signal_dataReceived(QByteArray data);
public slots:
  bool slot_sendData(QByteArray data);
  bool slot_openListener();
  void slot_closeListener();

public:
  bool isListening();
private slots:
  void slot_ReadData();
  //初始化函数
private:
  void initSerialPort();
public:
  LogSaver* getLogSaver();
  void setLogSaver(LogSaver* logSaver);
};

#endif
